<%@ page import="com.wuming.caiwu.security.SecurityHander" %><%--
  Created by IntelliJ IDEA.
  User: hanfei
  Date: 18/6/26
  Time: 下午5:49
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>缴费信息管理</title>
    <link rel="stylesheet" href="${allServerPath}static/layui/layui/css/layui.css">
    <link rel="stylesheet" href="${allServerPath}static/layui/css/formSelects-v4.css">
    <style>
        .query-condition {
            margin-top: 15px;
        }
    </style>
</head>
<body style="background-color: #f0f2f5;">
<div style="padding: 15px;margin: 15px;background-color: #fff;">
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>缴费信息管理</legend>
    </fieldset>
    <div class="layui-row query-condition" style="padding: 9px 15px;margin-bottom: 20px;">
            <button id="btnAdd" name="btnAdd" class="layui-btn layui-btn-normal">添加</button>
    </div>

    <table class="layui-hide" id="studentsInfo" lay-filter="demo" lay-data="{height: 'full-200'}">
    </table>
</div>

<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="detail">编辑</a>
    <a class="layui-btn layui-btn-xs" lay-event="del">删除</a>
</script>

<script src="${allServerPath}static/layui/layui/layui.js"></script>
<script>
    layui.config({
        base: '${allServerPath}static/layui/build/js/'
    }).extend({
        formSelects: 'formSelects-v4.min'
    }).use(['table', 'jquery','upload'], function () {
        var table = layui.table,
            $ = layui.jquery,
            upload = layui.upload;

        table.render({ //其它参数在此省略
            elem: '#studentsInfo'
            , url: '${allServerPath}web/payinfo/getAllInfos.htmls?t=' + Date.parse(new Date())
            , cols: [[ //表头
                {field: 'department', title: '管理部门', align: 'center', width: 400}
                , {field: 'payType', title: '收费项目', align: 'center', width: 400}
                , {field: 'payPrice', title: '收费金额', align: 'center', width: 400}
                , {field: 'payTime', title: '缴费时间', align: 'center', width: 400}
                , {fixed: 'right', title: '操作', align: 'center', toolbar: '#barDemo'}
            ]],

            where:{
              studentId: ${studentId}
            },
            id: 'studentContent',
            method: 'get', //如果无需自定义HTTP类型，可不加该参数
            page: false,
            limit: 10,
            request: {
                pageName: 'pageIndex', //页码的参数名称，默认：page
                limitName: 'pageSize'
            }, //如果无需自定义请求参数，可不加该参数
            response: {
                statusName: 'code' //数据状态的字段名称，默认：code
                , statusCode: 200 //成功的状态码，默认：0
                , msgName: 'message' //状态信息的字段名称，默认：msg
                , countName: 'total' //数据总数的字段名称，默认：count
                , dataName: 'data' //数据列表的字段名称，默认：data
            }, //如果无需自定义数据响应名称，可不加该参数
            done: function (res, curr, count) {
                //如果是异步请求数据方式，res即为你接口返回的信息。
                //如果是直接赋值的方式，res即为：{data: [], count: 99} data为当前页数据、count为数据总长度
                console.log(res);

                //得到当前页码
                console.log(curr);

                //得到数据总量
                console.log(count);
            },
            text: {
                none: '暂无相关数据' //默认：无数据。注：该属性为 layui 2.2.5 开始新增
            }
        });

        table.on('tool(demo)', function (obj) {
            var data = obj.data;
            if (obj.event === 'detail') {
                layer.open({
                    type: 2,
                    title: '编辑缴费信息',
                    maxmin: true,
                    shadeClose: false, //点击遮罩关闭层
                    area: ['570px', '59%'],
                    content: ['${allServerPath}web/payinfo/editPayinfo/' + data.id + '.htmls','no']
                })
            } else if (obj.event === 'del') {
                layer.confirm('确认删除?', function (index) {
                    $.ajax({
                            url: '${allServerPath}web/payinfo/delete/' + data.id + ".htmls",
                            method: 'get',
                            dataType: 'json',
                            success: function (result) {
                                if (result.success) {
                                    obj.del();
                                    layer.close(index);
                                    table.reload('studentContent', {});
                                }
                            },
                            error: function () {
                                layer.msg('删除失败,请稍后重试.');
                            }
                        }
                    );
                });
            }
        });

        $('#btnAdd').on('click', function () {
            console.log(111111111111)
            layer.open({
                type: 2,
                title: '添加缴费信息',
                maxmin: true,
                shadeClose: true, //点击遮罩关闭层
                area: ['570px', '59%'],
                end: function () {
                    table.reload('studentContent', {
                        page: {
                            curr: 1 //重新从第 1 页开始
                        }
                    });
                },
                content: ['${allServerPath}web/payinfo/add.htmls?studentId='+${studentId}]
            });
        });
    })

</script>
</body>
</html>
